import { BrowserRouter as Router, Switch, Route } from 'react-router-dom'

// 导入组件
import App from '../App'
import Home from '../pages/Home'
import User from '../pages/User'
import Fast from '../pages/Fast'
import Login from '../pages/Login'
import Register from '../pages/Register'
import Error from '../pages/Error'
import Practice from '../pages/Practice'
import Exam from '../pages/Exam'


// 创建路由组件
const router = () => //箭头函数后面加大括号{}需要在大括号里面加return（）如果不加大括号，就不需要return，只需要加（）即可
(
  <Router>
    <Switch>
      <Route path='/' component={() => (
        <App>
          <Switch>
            <Route exact path='/home' component={Home}></Route>
            <Route exact path='/user' component={User}></Route>
            <Route exact path="/fast" component={Fast}></Route>
            <Route exact path="/login" component={Login}></Route>
            <Route exact path="/register" component={Register}></Route>
            <Route exact path="/exam" component={Exam}></Route>
            {/* 路由传参/:参数？是参数可传可不传 */}
            <Route exact path="/practice/:actionCode" component={Practice}></Route>
            {/* <Route exact path="/practice/lianxi" component={Practice}></Route> */}
            <Route exact path="*" component={Error}></Route>
          </Switch>
        </App>
      )}></Route>

    </Switch>
  </Router>
)


export default router